<template>
 <div>
  御剑乘风来,除魔天地间!===father==={{$store.state.count}}
  ==={{count}}
  ==={{count2}}
  ===<button @click="add">啊~不要</button>
  ===合计:{{total}}
 </div>
</template>
<script>
import {mapGetters, mapState ,mapMutations} from 'vuex'
export default{
    name:'',
    data () {
        return {
            m:100
        }
    },
    created () {
      console.log(this.$store.state.count)
      
    },
    computed:{
      ...mapState(['count', 'count2']),
      ...mapGetters(['total']),
      count2(){
        return this.$store.state.count
      }
    },
    methods:{
      ...mapMutations(['addHandle']),
      add(){
        /* 点击触发mutations */
        /* 触发mutations中的函数需要使用 commit 方法 */
       /* this.$store.commit('mutations中定义好的函数',this.m)
       this.$store.commit('addHandle',this.m) */
       this.addHandle(this.m)
      },
      ayncAdd () {
         //触发actions中的函数
         //触发actions中的函数需要使用 dispatch
         console.log(this,111)
         //this.$store.disptch('syncHandle')
         this.ayncHandle(2)
         
      }
    }
}
</script>
<style lang='less'  scoped>
    
</style>
